package qz.lixinyu.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import qz.lixinyu.modules.sys.entity.QzEntity;
import qz.lixinyu.modules.sys.service.QzService;
import qz.lixinyu.common.utils.PageUtils;
import qz.lixinyu.common.utils.R;



/**
 * 
 *
 * @author lixinyu
 * @email 
 * @date 2025-02-27 14:43:05
 */
@RestController
@RequestMapping("sys/qz")
public class QzController {
    @Autowired
    private QzService qzService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:qz:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = qzService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:qz:info")
    public R info(@PathVariable("id") Long id){
		QzEntity qz = qzService.getById(id);

        return R.ok().put("qz", qz);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:qz:save")
    public R save(@RequestBody QzEntity qz){
		qzService.save(qz);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:qz:update")
    public R update(@RequestBody QzEntity qz){
		qzService.updateById(qz);

        return R.ok();
    }

    /**
     * 删除
     * 撤回简历
     * 1.删除user_qz的信息
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:qz:delete")
    public R delete(@RequestBody Long[] ids){
		qzService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

    /**
     * 同意录取
     * @param
     * @return
     */
    @RequestMapping("/approve")
    @RequiresPermissions("sys:qz:approve")
    public R approve(@RequestParam Map<String, Object> params){
        Long qzId = Long.valueOf(params.get("qzId").toString());
        qzService.approve(qzId);
        return R.ok();
    }
    /**
     * 拒绝简历
     */
    @RequestMapping("/reject")
    @RequiresPermissions("sys:qz:reject")
    public R reject(@RequestParam Map<String, Object> params){
        Long qzId = Long.valueOf(params.get("qzId").toString());
        qzService.reject(qzId);
        return R.ok();
    }

}
